package com.example.index.gesture

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.ScaleGestureDetector
import com.example.index.R
import kotlinx.android.synthetic.main.activity_gesture_scale_detect.*

class GestureScaleDetectActivity : AppCompatActivity() {

    val TAG = "GestureScaleDetectActivity"
    lateinit var scaleDetector: ScaleGestureDetector

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_gesture_scale_detect)


        scaleDetector = ScaleGestureDetector(this, object : ScaleGestureDetector.OnScaleGestureListener {

            override fun onScaleBegin(detector: ScaleGestureDetector?): Boolean {

                return true
            }

            override fun onScaleEnd(detector: ScaleGestureDetector?) {
            }

            override fun onScale(detector: ScaleGestureDetector?): Boolean {
                Log.i(TAG,"currentSpan:${detector?.currentSpan}")
                Log.i(TAG, "onScale: currentSpanX：${detector?.currentSpanX}")
                Log.i(TAG, "onScale: ${detector?.scaleFactor}")
//                Log.i(TAG, "onScale: ${detector?.scaleFactor}")
//                xm.scaleX = detector!!.scaleFactor
//                xm.scaleY = detector.scaleFactor
                return true
            }

        })

//        xm.setOnTouchListener { v, event ->
//            scaleDetector.onTouchEvent(event)
//            return@setOnTouchListener true
//        }
    }
}
